﻿<?php echo $html->script("lib/jquery.datepicker.min.js");?>
<?php echo $html->css("screen/presses_staff.css");?>
<?php echo $html->css("screen/page_2_row.css");?>
<?php echo $this->element('menu', array("active" => "3.a"));?>
<script>
$(document).ready(function(){
try{
	$("#Search").validate({
		rules: {
			'size': {
				paper_size: true
			},
			'colour':{
				number:true
			}
			
		},
		messages: {
		}
	});
	$.validator.addMethod(
		"paper_size",
		function(value, element) {
			if (value=="") return true;
			return value.match(/^\d+?x\d+$/);
		},
		"Please enter a date in the format dxd"
	);	
	$('.jqTransform').jqTransform({width:100});
}catch(e){
	alert(e);
}
});
	function search(){
		if (!$("#Search").valid()) return;
		var url="<?php echo $this->webroot;?>admin/presses/index";
		
		if ($("#search_serial").val()!=""){
			url=url+"/serial:"+$("#search_serial").val();
		}
		if ($("#search_make").val()!=""){
			url=url+"/make:"+$("#search_make").val();
		}
		if ($("#search_size").val()!=""){
			url=url+"/size:"+$("#search_size").val();
		}
		if ($("#search_special").val()!=""){
			url=url+"/special:"+$("#search_special").val();
		}
		if ($("#search_stock").attr("checked")){
			url=url+"/stock:1";
		}else{
			url=url+"/stock:0";
		}
		if ($("#search_colour").val()!=""){
			url=url+"/colour:"+$("#search_colour").val();
		}		
		window.open(url,"_self");
	}
</script>
<ul class="breadcrumb">
        <li>
          <?php echo $this->Html->link(__('Press  ', true), array('action' => 'index'), array('class'=>'fist_link'));?>
        </li>
        <li>
          <a href="#" >List Press</a>
        </li>
</ul>	
<div id="content">
	<div id="left" class="hight_resize" style="padding-top:15px;">
	<?php echo $session->flash();?>	
		<div class="table table_p8 boder presses_table">
			<table>
				<thead> 
					<tr>
						<td style="width:20%">Press</td> 
						<td>Type</td> 
						<td>Colour</td> 
						<td>Year</td> 
						<td>Specials</td> 
						<td style="width:20%">Sheet Size</td> 
						<td style="width:5%"></td> 
					</tr>
				</thead> 
				</tbody>
				   <?php foreach($presses as $press){ ?>  
						<tr> 
							<td><?php echo $press['Press']['name']; ?> </td> 
							<td><?php echo $press['PressType']['name']; ?> </td> 
							<td><?php echo $press['Press']['colour']; ?> </td> 
							<td><?php echo $press['Press']['year']; ?> </td> 
							<td><?php echo $press['Press']['perfect']; ?> </td> 
							<td><?php echo $press['Press']['paper_size1']; ?>x<?php echo $press['Press']['paper_size2']; ?> </td> 
							<td><?php echo $html->link('Edit',array('action'=>'edit',$press['Press']['id'])); ?>&nbsp;|
							<?php echo $html->link('Remove',array('action'=>'delete',$press['Press']['id'])); ?></td> 
						</tr> 
					<?php } ?>
				</tbody>
			</table> 
		</div>
		<?php echo $this->Paginator->numbers(); ?>
		<?php echo $this->Paginator->counter(); ?>
		<div><?php echo $html->link(__('Add Press', true),array('action'=>'add'),array('class'=>'bt bt_save'));?></div>
	</div>
	<div id="right" class="hight_resize">
		<fieldset class="form">
            <form method="post" name="Search" id="Search" action="" onsubmit="search();return false;">
                <div class="input">
                    <label class="w100">Machine number:</label>
                    <input type="text" id="search_serial" name="serial" value="<?php echo_paginate("serial",$paginates);?>" class="w140"/>                    
                </div>
                <div class="input">

                    <label class="w100">Manufacture:</label>
                    <input id="search_make" name="make" type="text" value="<?php echo_paginate("make",$paginates);?>" class="w140"/>                
                </div>
                <div class="input">
                    <label class="w100">Sheet size:</label>
                    <input type="text" id="search_size" name="size" value="<?php echo_paginate("size",$paginates);?>" class="w140"/>                    
                </div>
                <div class="input">
                    <label class="w100">Colours:</label>
                    <input id="search_colour" type="text" name="colour" value="<?php echo_paginate("colour",$paginates);?>" class="w140"/>                    
                </div>

                <div class="input">
                    <label class="w100">Special features:</label>
                    <input id="search_special" type="text" name="special" value="<?php echo_paginate("special",$paginates);?>" class="w140"/>                    
                </div>
                <div class="input">
                    <label class="w100">In stock:</label>
                    <input id="search_stock" type="checkbox" <?php if(!empty($paginates["stock"]) && $paginates["stock"]=='1') echo "checked";?>/>
                </div>
                <div style="width:100%;display:block;">
                    <center><input type="submit" onclick="search();" value="Search" class="bt" style="float:none !important;" /></center>					
                </div>
            </form>
        </fieldset>
	</div>
</div>
<?php
	function echo_paginate($field,$paginates){		
		if(!empty($paginates[$field]))
			echo $paginates[$field];
	}
?>